import React from 'react';
import { Image as AntdImage } from 'antd';
import type { ImageProps as AntdImageProps } from 'antd';
import { createStyles } from 'antd-style';

export interface ImageProps extends AntdImageProps {
  /**
   * @description 自定义样式类名
   */
  customClassName?: string;
}

const useStyles = createStyles(({ token, css }) => ({
  image: css`
    border-radius: ${token.borderRadius}px;
  `,
}));

const ImageComponent: React.FC<ImageProps> = ({ customClassName, className, ...restProps }) => {
  const { styles, cx } = useStyles();
  
  const imageClassName = cx(
    className,
    customClassName,
    styles.image
  );

  return <AntdImage className={imageClassName} {...restProps} />;
};

const Image = Object.assign(ImageComponent, {
  PreviewGroup: AntdImage.PreviewGroup,
});

export { Image };
export default Image;

